#include "LoadingScene.h"
#include "GameScene.h"

TargetScene _targetScene;
int _id;
void LoadingScene::sceneWithTargetSource(TargetScene target,int id)
{
	_targetScene =target;
	_id =id;

	CCLabelTTF *label = CCLabelTTF::create("Loading...", "Arial", 18);
	CCSize winSize =CCDirector::sharedDirector()->getWinSize();
	label->setPosition(ccp(winSize.width/2,winSize.height /2));
	this->addChild(label);
	//this->schedule(schedule_selector(LoadingScene::targetSourceCallback));
	this->scheduleOnce(schedule_selector(LoadingScene::targetSourceCallback),0.1);
	//CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(LoadingScene::targetSourceCallback),this,0.1,false);
}

void LoadingScene::targetSourceCallback(float cctime)
{
	//this->unschedule(schedule_selector(LoadingScene::targetSourceCallback));

	switch (_targetScene) {
	case TargetSceneGame:
		{
			CCScene *scene =	GameLayer::scene(_id);
			CCDirector::sharedDirector()-> replaceScene(scene);
			//scene->autorelease();
			
		}
		break;
	default:
		break;
	}
}
